import { observer } from "mobx-react";
import { WeaSelect, WeaLocaleProvider, WeaCheckbox } from 'ecCom';
import { toJS } from 'mobx';
import { Button } from 'antd';
const getLabel = WeaLocaleProvider.getLabel;

@observer
export default class DownloadCondition extends React.Component {
    componentDidMount() {
        const { store } = this.props;
        store.relatedLayout = this.container;
    }
    render() {
        const { store } = this.props;
        const { fieldOptions, nativeFields, conditionList, relatedLayout, name } = store;
        return (
            <div className="edc-ds-condition" ref={ref => this.container = ref}>
                <div className="edc-ds-condition-header">导出设置</div>

                <div className="edc-ds-condition-content1">
                    <div className="ant-col-12 text-elli" title={`导出附件`}>
                        {'导出附件'}{name}
                    </div>
                    <WeaCheckbox
                        value={store.excelStore.isdownload}
                        display="switch"
                        id='test'
                        onChange = {store.excelStore.updateIsDownloadField}
                        style={{ display: 'inline' }}
                    />

                    <div className="ant-col-12 text-elli" title={`文件夹名称`}>
                        {'文件夹名称'}{name}
                    </div>
                    {relatedLayout && <WeaSelect
                        layout={relatedLayout}
                        value={store.excelStore.fieldgroup}
                        onChange={(value, key, h) => this.updateDownloadCondition(value, key, h)}
                        options={fieldOptions}
                        style={{ width: 100, marginRight: 10 }}
                    />}

                </div>

                <div className="edc-ds-condition-setting-opt">

                    <Button type="small" onClick={this.hide}>{getLabel('31129', '取消')}</Button>
                    <Button type="small" onClick={store.excelStore.saveDownloadCondition}>{'保存'}</Button>
                </div>
            </div>
        )

    }
    updateDownloadCondition = (value, key, h) => {
        const { store } = this.props;
        store.excelStore.updateDownloadCondition(value)
    }

    hide = () => {
        const { store } = this.props;
        store.downloadPopverVisible = false;
    }
}